package IOperation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-01-02
 * Time: 20:16
 */
public class FindOperation implements Operation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入要查找的书名:");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        int size=bookList.getUseSize();
        for (int i = 0; i <size ; i++) {
            Book book=bookList.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("找到了,该书信息如下:");
                System.out.println(book);
                return;
            }
        }
        System.out.println("未查到此书");
    }
}
